<html>
<head>
<meta charset="UTF-8" />
	<link th:href="@{easyui/themes/insdep/easyui.css}" rel="stylesheet" type="text/css" />
	<link th:href="@{easyui/themes/insdep/master.css}" rel="stylesheet" type="text/css" />
	<link th:href="@{easyui/themes/insdep/icon.css}" rel="stylesheet" type="text/css" />
	
	<script type="text/javascript" th:src="@{easyui/jquery.min.js}"></script>
	<script type="text/javascript" th:src="@{easyui/jquery.easyui.min.js}"></script>
	<script type="text/javascript" th:src="@{vendors/moment/min/moment.min.js}"></script>
	<script type="text/javascript" th:src="@{easyui/themes/insdep/jquery.insdep-extend.min.js}"></script>
    <script type="text/javascript">			
	function status(value,row,index)
	{
		 return value === 0 ?
		'<span class="label label-danger">禁用</span>' : 
		'<span class="label label-success">正常</span>';
	}
	function createTime(value,row,index)
	{
	 return moment(value).format('YYYY-MM-DD HH:mm:ss');
	}
	function tobutton(value,row,index){
		return '<a href="#" class="button-delete button-danger" onclick="delUser('+row.userId+')">删除</a> <a href="#" class="button-edit button-default" onclick="updateUser('+row.userId+')">修改</a>';

	}
	function delUser(id){
		$('#dlg').dialog('open');
	}
	function delUserPlus(){
		$('#dlg').dialog('close');
		var row = $('#dg').datagrid('getSelected');
		var id=row.userId;
		$.ajax({
			  type: 'POST',
			  url: '/deluser',
			  data: {id:id},
			  dataType : 'json',
			  success : function(result) { 
				  $.messager.show({
			             title:'提示',
			             msg:'删除成功',
			             showType:'show'
			         });
				  $('#dg').datagrid('reload'); 
			  },
			  error : function(errorMsg) {  
				  $.messager.show({
			             title:'提示',
			             msg:'数据传输失败',
			             showType:'show'
			         });
			  }
			  
			});
		
		
		
		
		
	}
	function updateUser(row){
		$('#dlg-update').dialog('open');
		
	}
    $(function(){
    	 myTable = $("#dg").datagrid({
    		 	//fit:true,
    	    	rownumbers:true,
    	        url : "/getuser",
    	        method : 'POST',
    	        loadMsg : "请稍等，数据加载中...",
    	        pagination : true,
    	        pageList : [15,30,60,90],//可以设置每页记录条数的列表
    	        pageSize : 15,//每页显示的记录条数，默认为50
    	        singleSelect:true,
                columns:[[
						
					    {title:'用户编号',field:'userId',align:'center',width:50},
					    {title:'用户名',field:'userName',align:'center',width:80},
					    {title:'用户密码',field:'userPassword',align:'center',width:50},
					    {title:'部门',field:'userName',align:'center',width:100},
					    {title:'角色',field:'roleIdList',align:'center',width:100},
					    {title:'状态',field:'status',align:'center',width:80,formatter:status},
					    {title:'手机号码',field:'mobile',align:'center',width:100},
					    {title:'创建时间',field:'createTime',align:'center',width:150,formatter:createTime},
					    {title:'操作',field:'button',align:'center',width:100,formatter:tobutton}
					    ]]
    	 
    	    });
    })
    
           
    
    </script>
    <style>.label-top{ margin:0 0 10px; display:block;}</style>
    </head>
    <body>
    <div style="width:98%;height:96%;margin:0 auto;">
		     <table id="dg" style="width:100%;height:90%;border:1px solid #ccc;">
		     </table>
    </div>
    
  	<!-- 删除对话框 -->
    <div id="dlg" class="easyui-dialog" title="提示" data-options="closed:true,cls:'theme-panel-red', buttons: '#dlg-buttons'" style="width:200px;height:140px;padding:10px">
        		确认删除这条记录吗？
    </div>
     <div id="dlg-buttons" style="background-color:white">
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="delUserPlus()">确认</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:$('#dlg').dialog('close')">取消</a>
    </div>
    
    <!-- 修改用户信息 -->
   <!-- 添加用户form -->
   <div id="dlg-update" title="用户信息"  class="easyui-dialog" style="width:450px;height:400px;padding:10px 20px"
            closed="true" buttons="#update-dlg-buttons">
         <form id="ff" class="easyui-form" method="post" data-options="novalidate:true">
             <div style="margin-bottom:20px">
            <label class="label-top">密码表单:</label>
            <input class="easyui-textbox" type="text" name="name" data-options="required:true"></input>
        </div>
            
        </form>
    </div>
    <div id="update-dlg-buttons">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveInfo()" style="width:90px">保存</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg-update').dialog('close')" style="width:90px">取消</a>
    </div>
    </body>
</html>